package database;

public class Availability {

    public Availability() {
        week = new Day[7];
        username = "hidden";
    }

    ;
    public Availability(String username) {
        week = new Day[7];
        this.username = username;
    }

    public Day getDay(int day)
    {
        if (week[day] == null) {
            week[day] = new Day();
        }
        return week[day];
    }

    public int[] getDayIntForm(int weekday) {
        int[] ans = new int[24];
        boolean[] check = week[weekday].getWholeDay();
        for (int i = 0; i < 24; i++) {
            if (check[i]) {
                ans[i] = 1;
            } else {
                ans[i] = 0;
            }
        }
        return ans;
    }

    public void setDayIntForm(int[] times, int weekday) throws Exception {
        if (times.length != 24) {
            throw new Exception("input array is smaller than 24");
        }
        boolean[] ans = new boolean[24];
        for (int i = 0; i < 24; i++) {
            if (times[i] == 1) {
                ans[i] = true;
            } else {
                ans[i] = false;
            }
        }
        week[weekday] = new Day(ans);
    }

    public void setDay(int index, Day day) {
        week[index] = day;
    }

    public void setDay(int index, boolean[] day) throws Exception {
        if (day.length != 24) {
            throw new Exception("The array is not the correct size for array");
        }
        week[index] = new Day(day);
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String _username) {
        username = _username;
    }
    private Day[] week;
    private String username;
};
